CC 	= gcc
INSTALL	= install
IFLAGS  = -I/usr/local/include -I../../csf/include -I../../csf/monitor -I../../csf/confparser -I../
CFLAGS	= $(cflags)
PREDEF = $(pdef)
LDFLAGS = -shared -fPIC -L/usr/local/lib -L../../lib -lconfparser -lprotocol -lmonitor

LINK	= -Wl
OBJS	= http.o http_request.o http_serve_funcs.o
DIRS	= ./http_io ./http_upload
WARN    = $(warn)

VARLIST	= cflags="$(CFLAGS)" pdef="$(PREDEF)" warn="$(WARN)"

.PHONY: clean

.c.o:
	@(echo "start to compile http"); 
	$(CC) $(WARN) -c $*.c $(CFLAGS) $(IFLAGS) $(PREDEF)

http.so: $(OBJS)
	$(CC) $(IFLAGS) -o $@ $(DEBUG) $(OBJS) $(LINK) $(LDFLAGS)
	mv -f $@ ../../bin/; \
        set -e; for i in $(DIRS); do \
         (set -e; echo "[$$i]"; cd $$i; \
         $(MAKE) -f freebsd.mk $(VARLIST)) || exit 1; \
        done;
clean:
	@(echo "clean"); 
	rm -f $(OBJS) \
        set -e; for i in $(DIRS); do \
         (set -e; echo "[$$i]"; cd $$i; \
         $(MAKE) -f freebsd.mk clean) || exit 1; \
        done;
	rm -f *.o ../../bin/http.so


